home *** CD-ROM | disk | FTP | other *** search
- Path: ecf2.puc.edu!bivey
- From: bivey@ecf2.puc.edu (Bruce Ivey)
- Newsgroups: comp.lang.c
- Subject: Re: Help, best way to compare doubles
- Date: 16 Jan 1996 05:43:17 GMT
- Organization: CRL Dialup Internet Access
- Message-ID: <4dfdtl$phv@nntp.crl.com>
- References: <4da169$mm4@mercury.IntNet.net>
- NNTP-Posting-Host: ecf2.puc.edu
-
- Jeff Tomich (jtomich@IntNet.net) wrote:
- : Looking for a way to compare doubles for equality.
-
- : thanks, Jeff
-
- The first question to ask is "how equal"? In general, one picks some
- error limit, such as e = 1E-6; then uses it in this form:
-
- if (fabs(n1 - n2) < e) // then they are considered equal
- else // they are considered different
-
- -----------------------------------------------------------------------------
- Bruce Ivey Dept of Physics & Computer Science Pacific Union College
- Angwin, CA 94508 bivey@puc.edu (707) 965-7269
- =============================================================================
-